<template>
  <a-card :bordered="false">
    <super-query :fieldList="tableObj.columns" @ok="handleSuperQuery"/>
    <v-table
      ref="table"
      :data="loadData"
      :columns="tableObj.columns"
    >
      <template v-slot:buttons>
        <a-button @click="$refs.orderForm.init('','add')" icon="plus" type="primary">新增入库单</a-button>
      </template>
      <span slot="action" slot-scope="{ row,text }">
        <span>
          <a href="javascript:;" @click="show(row)">查看订单详情</a>
        </span>
      </span>
    </v-table>
    <order-form @ok='queryPage' ref='orderForm'></order-form>
  </a-card>
</template>

<script>
import { fetchList } from '@/api/side/warehouseOrder'
import { TableMixin } from '@/mixins/TableMixin'
import SuperQuery from '@comp/SuperQuery/SuperQuery'
import { tableObj } from './template'
import OrderForm from '@/views/main/side/warehouseOrder/OrderForm'
export default {
  name: 'PlanDay',
  mixins: [TableMixin],
  components: {
    SuperQuery,
    OrderForm
  },
  data () {
    return {
      tableObj,
      dataSource: [],
      loadData: parameter => {
        return fetchList(
          Object.assign(parameter, this.queryParam)
        ).then(res => {
          return res.data
        })
      }
    }
  },
  methods: {
    // edit (record) {
    //   this.$refs.lineForm.init(record.lineCode, 'edit')
    // },
    handleSuperQuery (params) {
      console.log(params,'params')
      if(params){
        this.queryParam.queryType = params.queryType
        this.queryParam.queryItems = encodeURI(JSON.stringify(params.queryItems))
      }else{
        this.queryParam.queryType = ''
        this.queryParam.queryItems = ''
      }
      this.queryPage()
    },
    show(row){
      this.$refs.orderForm.init(row.orderCode,'show')
    }
  }
}
</script>

<style scoped>

</style>
